package com.yuwj.chinaa.util;

import com.github.mikephil.charting.components.AxisBase;
import com.github.mikephil.charting.formatter.IAxisValueFormatter;

import java.util.List;

public class XAxisValueFormatter implements IAxisValueFormatter {

    // 区域值
    private List<String> mStrs;
    /**
     * 对字符串类型的坐标轴标记进行格式化
     *
     * @param strs
     */
    public XAxisValueFormatter(List<String> strs) {
        this.mStrs = strs;
    }


    @Override
    public String getFormattedValue(float value, AxisBase axis) {
        System.out.println(value+"");
        System.out.println(axis.toString());
        if(mStrs.size()<=0){
            return "";
        }
        else if(value < mStrs.size()){
            String obj = mStrs.get((int) ((value+mStrs.size()*5) % mStrs.size()));//防止数组越界

                return obj;

        }
        else{
            return "";
        }


    }
}
